#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define vec vector<int>
#define y1 y_____hahahaha_____1

using namespace std;

typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef long double ldb;

int read(){int x = 0,sgn = 1;char ch = getchar();for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;for(;isdigit(ch);ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48); return x * sgn;}

const int N = 1e6+10;
const int mod = 998244353;

int qp(int x,int t){int res = 1;for(;t;t >>= 1,x = (ll) x * x % mod) if(t & 1) res = (ll) x * res % mod;return res;}

char s[N];
int fac[N<<1],ifac[N<<1],n,ans;

void init(int l){for(int i = (fac[0] = 1);i <= l;i++) fac[i] = (ll) fac[i - 1] * i % mod;  ifac[l] = qp(fac[l],mod-2); for(int i = l - 1;i >= 0;i--) ifac[i] = (ll) ifac[i + 1] * (i + 1) % mod;}

int upd(int x){return x + (x >> 31 & mod);}

int C(int x,int y){return x < 0 || y < 0 || x < y ? 0 : (ll) fac[x] * ifac[y] % mod * ifac[x - y] % mod;}

int main(){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	scanf("%s",s + 1); n = strlen(s + 1); init(n << 1);
	int l1 = 0,l2 = 0,r1 = 0,r2 = 0; for(int i = 1;i <= n;i++) r1 += s[i] == '?',r2 += s[i] == ')';
	for(int i = 1;i < n;i++){
		l1 += s[i] == '?'; l2 += s[i] == '('; r1 -= s[i] == '?'; r2 -= s[i] == ')';
		int d = r1 + r2 - l2; ans = upd(ans + (ll) C(l1 + r1,d) * l2 % mod - mod);
		ans = upd(ans + (ll) l1 * C(l1 + r1 - 1,d - 1) % mod - mod);
	}
	ans = upd(ans);
	printf("%d\n",ans);
	return 0;
}
